package com.b.sts.service.impl;

import com.b.sts.entity.AnnouncementEntity;
import com.b.sts.mapper.AnnouncementMapper;
import com.b.sts.service.AnnouncementService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 公告表 服务实现类
 * </p>
 *
 * @author b
 * @since 2023-07-12
 */
@Service
public class AnnouncementServiceImp extends ServiceImpl<AnnouncementMapper, AnnouncementEntity> implements AnnouncementService {
    @Resource
    AnnouncementMapper mapper;

    @Override
    public AnnouncementEntity get(Integer id) {
        return mapper.selectById(id);
    }

    @Override
    public List<AnnouncementEntity> list(AnnouncementEntity entity) {
        QueryWrapper<AnnouncementEntity> wrapper = new QueryWrapper<>();
        wrapper.setEntity(entity);
        return mapper.selectList(wrapper);
    }

    @Override
    public boolean add(AnnouncementEntity entity) {
        return mapper.insert(entity) > 0;
    }

    @Override
    public boolean del(Integer id) {
        return mapper.deleteById(id) > 1;
    }

    @Override
    public boolean update(AnnouncementEntity entity) {
        return mapper.updateById(entity) > 1;
    }
}
